package com.appspringboot.common;

import java.util.HashMap;


public class BIException extends RuntimeException{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private int exceptionCode;

	private String msgEN = "";

	public static final int ORDER_NOT_FOND = 300;

	public static final HashMap<Integer, String> exceptionMsgMap = new HashMap<Integer, String>() {
		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

		{
			put(UNKNOWN_ERROR, "未知错误!");
			put(PHONE_EXIST_ERROR_CODE, "手号已存在!");
			put(PHONE_EMAIL_ERROR_CODE, "邮箱不存在!");

		}
	};
	public static final int UNKNOWN_ERROR = 1;

	/**
	 * 手机号存
	 */
	public static final int PHONE_EXIST_ERROR_CODE = 10;

	/**
	 * Email号存
	 */
	public static final int PHONE_EMAIL_ERROR_CODE = 11;

	/**
	 * 少参数
	 */
	public static final int LESS_PARAMETERS = 2;
	/**
	 * 无权操作 非法操作
	 */
	public static final int NOT_AUTHORITY = 3;
	/**
	 * 字符不可处理
	 */
	public static final int FIELD_NOT_EDITING = 4;
	/**
	 * 支付错误
	 */
	public static final int PAY_ERROR = 20;
	/**
	 * 无效线路
	 */
	public static final int ORDER_INVALID_ROUTE = 21;
	/**
	 * 无效COUPONS
	 */

	public static final int ORDER_INVALID_COUPONS = 22;
	/**
	 * 订单无效
	 */
	public static final int ORDER_INVALID = 23;
	/**
	 * 订单状态错误
	 */
	public static final int ORDER_STATE_ERROR = 24;

	public static final int ORDER_MORE_THAN_RETURN_PERIOD = 25;
	/**
	 * 重复评价
	 */
	public static final int REPEAT_EVALUATION = 26;

	/**
	 * 缺少签名
	 */
	public static final int LESS_SIGNATURE = 102;
	/**
	 * 缺少参数
	 */
	public static final int LESS_ARGUMENTS = 103;

	/**
	 * 订单无效
	 */
	public static final int UID_INVALID = 26;

//	public BIException(ExceptionConstant exceptionConstant) {
//
//		this(exceptionConstant.getExceptionInfo().getCode(), exceptionConstant.getExceptionInfo().getMsg(),exceptionConstant.getExceptionInfo().getMsgEN());
//
//	}

	public BIException(Integer exceptionCode) {
		this(exceptionCode, exceptionMsgMap.get(exceptionCode));

	}

	public BIException(int exceptionCode, String msg) {
		this(exceptionCode, msg, "");
	}

	public BIException(int exceptionCode, String msg, String msgEN) {
		super(msg);
		this.exceptionCode = exceptionCode;
		this.msgEN = msgEN;
	}

	public int getExceptionCode() {
		return exceptionCode;
	}

	@Override
	public synchronized Throwable fillInStackTrace() {

		return this;
	}

	@Override
	public StackTraceElement[] getStackTrace() {
		return null;
	}

	public String getMsgEN() {

		return this.msgEN;
	}
}
